app.controller('shopLocatedIntegralCtrl',['$scope','utilService','shopLocatedIntegralService','$modal','$stateParams','toaster','$state', function($scope,utilService,shopLocatedIntegralService,$modal,$stateParams,toaster,$state) {
    $scope.shopLocatedIntegralVO={};
    //查询商品列表
    $scope.findPageAll = function () {
        utilService.queryForPagingList($scope, {
            url: $scope.app.domain + '/shop/located/integral',
            params: $scope.shopLocatedIntegralVO
        }).then(function (result) {
        });
    }

    $scope.findPageAll();

    $scope.returnIntegral = function(id,type){
        var param = {
            shopLocatedIntegralId:id,
            type:type,
        };
        // query data.
        openModal("返还用户积分");

        function openModal(msg){
            utilService.modal($modal, $scope, {
                title:"返还用户积分",
                controller:"returnIntegralCtrl",
                message:msg,
                data:param
            });
        }
    }

}]);


app.controller('returnIntegralCtrl', ['$scope', '$modalInstance','$state','shopLocatedIntegralService','toaster','modalData',
    function($scope, $modalInstance,$state,shopLocatedIntegralService,toaster,modalData) {
        $scope.modal = modalData;
        $scope.userEditVO=modalData.data;

        $scope.ok=function(){
            shopLocatedIntegralService.returnIntegral($scope).then(function(result){
                switch (result.status){
                    case 200:
                        toaster.pop('success', "提示", "操作成功");
                        $scope.findPageAll();
                        $modalInstance.close("success");
                        break;
                    case 670:
                    case 724:
                    case 725:
                        toaster.pop('waiting', "提示", result.message);
                        break;
                    default :
                        toaster.pop('error', "操作失败", "发生未知错误！请联系管理员");
                        break
                }
            });
        }

        //取消弹窗
        $scope.cancel = function () {
            $modalInstance.dismiss('cancel');
        };
    }
]);